package com.briup.estore.common.dao;

import com.briup.estore.common.bean.Order;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author adam
 * @date 2022/1/12
 */
@Repository
public interface IOrderDao extends JpaRepository<Order, String> {
    List<Order> findByUserIdOrderByCreateDate(Long id);

    Page<Order> findByIdContainsAndStatusContainsOrderByCreateDateDesc(String id, String status, Pageable pageable);

    @Modifying
    @Query(value = "update  Order  set status=?2 , distributionMode=?3 ,trackingNumber=?4 where id=?1")
    void updateOrder(String id, String status, String distributionMode, String trackingNumber);

    @Modifying
    @Query(value = "update  Order  set status=?2 where id=?1")
    void updateOrder(String id, String status);
}
